package com.design.prototypepattern.shallow;

import java.util.List;

/**
 * @auther LiZiBa
 * @date 2020/8/8 23:47
 * @description: Cloneable接口在Object定义，为native方法无法查询源码
 *               protected native Object clone() throws CloneNotSupportedException;
 *
 *               重点：浅克隆对引用类型克隆的是地址会出现数据共享的情况
 **/
public class Course implements Cloneable{

    private String name;
    private String time;
    private List<String> teacher;

    public Course() {
    }

    public Course(String name, String time, List<String> teacher) {
        this.name = name;
        this.time = time;
        this.teacher = teacher;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public List<String> getTeacher() {
        return teacher;
    }

    public void setTeacher(List<String> teacher) {
        this.teacher = teacher;
    }

    @Override
    public String toString() {
        return "Course{" +
                "name='" + name + '\'' +
                ", time='" + time + '\'' +
                ", teacher=" + teacher +
                '}';
    }

    @Override
    public Course clone() throws CloneNotSupportedException {
        return (Course) super.clone();
    }
}
